package com.moji.controller.api;


import com.moji.common.Commons;
import com.moji.common.base.ApiResult;
import com.moji.common.config.OperateLog;
import com.moji.common.entity.MyPage;
import com.moji.entity.SysMenu;
import com.moji.entity.dto.PrOnOffDto;
import com.moji.entity.dto.QuerySysMenuDto;
import com.moji.service.SysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-07-23
 */
@RestController
@RequestMapping("api/sysMenu")
@Api(tags = "菜单信息", value = "菜单信息接口")
public class SysMenuController {

    @Resource
    private SysMenuService sysMenuService;

    @PostMapping("add")
    @ApiOperation("保存菜单信息数据")
    @OperateLog(moduleName = "菜单管理",content = "保存菜单信息",operateType = Commons.OPERATE_TYPE.ADD)
    public ApiResult add(@RequestBody SysMenu ccpSystemMenu){
        ApiResult apiResult = sysMenuService.add(ccpSystemMenu);
        return apiResult;
    }

    @PostMapping("update")
    @ApiOperation("编辑菜单信息数据")
    @OperateLog(moduleName = "菜单管理",content = "编辑菜单信息",operateType = Commons.OPERATE_TYPE.EDIT)
    public ApiResult update(@RequestBody SysMenu ccpSystemMenu){
        ApiResult apiResult = sysMenuService.edit(ccpSystemMenu);
        return apiResult;
    }

    @GetMapping("delete")
    @ApiOperation("删除菜单信息数据")
    @OperateLog(moduleName = "菜单管理",content = "删除菜单信息",operateType = Commons.OPERATE_TYPE.DELETE)
    public ApiResult delete(Long id){
        ApiResult res = sysMenuService.delete(id);
        return res;
    }
    @PostMapping("queryPage")
    @ApiOperation("分页查询菜单信息数据")
    public ApiResult queryPage(@RequestBody QuerySysMenuDto dto){
        MyPage<SysMenu> ccpSystemMenuMyPage = sysMenuService.queryPage(dto);
        return ApiResult.ok(ccpSystemMenuMyPage);
    }

//    @PostMapping("queryMenuTree")
//    @ApiOperation("查询菜单树形数据(查询启用)")
//    public ApiResult queryMenuTree(@RequestBody QuerySysMenuDto dto){
//        return ApiResult.ok(sysMenuService.queryMenuTree(dto));
//    }

    @PostMapping("queryAllMenuTree")
    @ApiOperation("查询菜单树形数据(查询全部)")
    public ApiResult queryAllMenuTree(@RequestBody QuerySysMenuDto dto){
        return ApiResult.ok(sysMenuService.queryAllMenuTree(dto));
    }

    @PostMapping("updateMenuStatus")
    @ApiOperation("更新菜单启停状态")
    public ApiResult updateMenuStatus(@RequestBody PrOnOffDto prOnOffDao){
        return ApiResult.ok(sysMenuService.updateMenuStatus(prOnOffDao));
    }

    @GetMapping("queryList")
    @ApiOperation("查询菜单列表数据(查询启用)")
    public ApiResult queryList(){
        return ApiResult.ok(sysMenuService.queryList());
    }
}

